package com.team.controller;

import com.team.entity.Admin;
import com.team.service.LoginService;
import com.team.util.WebUtil;
import com.team.vo.LoginVo;
import com.team.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author WHZ
 * @date 2022年10月15日 10:33
 */
@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 根据admin账号和密码登陆
     * @param loginVo
     * @return
     */
    @RequestMapping("/admin")
    public Result disembarkByAdmin(@RequestBody LoginVo loginVo){
        return loginService.disembarkByAdmin(loginVo.getName(),loginVo.getPassword());
    }

    /**
     * 获取登录员工的信息
     *
     * @author 太阳偷渡青山
     * @return {@link Result}
     */
    @RequestMapping("loginAdmin")
    public Result loginAdmin(){
        return loginService.getLoginAdmin();
    }

    /**
     * 退出账号
     *
     * @author 太阳偷渡青山
     * @return {@link Result}
     */
    @RequestMapping("quit")
    public Result quit(){
        return loginService.quit();
    }
}
